import request from "@/utils/request";
import { AxiosPromise } from "axios";

/**
 * 获取公司信息
 *
 * @param queryParams
 */
export function getCompany(id: number){
  return request({
    url: "/api/v1/company/getInfo/" + id,
    method: "get",
  });
}

/**
 * 保存公司设置
 *
 * @param data
 */
export function saveCompany(data) {
  return request({
    url: "/api/v1/company",
    method: "post",
    data: data,
  });
}

/**
 * 删除公司
 *
 * @param ids
 */
export function deleteCompanies(ids: string) {
  return request({
    url: '/api/v1/company/' + ids,
    method: 'delete'
  });
}

/**
 * 获取公司列表
 *
 * @param queryParams
 */
export function getCompanyList() {
  return request({
    url: "/api/v1/company/list",
    method: "get",
  });
}

/**
 * 店铺分页数据
 *
 * @param queryParams
 */
export function getCompanyPage(queryParams){
  return request({
    url: '/api/v1/company/page',
    method: 'get',
    params: queryParams
  });
}

/**
 * 导出入账主体
 *
 * @param ids
 * @returns
 */
export function exportCompany(ids: any) {
	return request({
		url: '/api/v1/company/_export?ids='+ids,
		method: 'get',
		responseType: 'arraybuffer'
	});
}

/**
 * 导入入账主体
 *
 * @param file
 */
export function importCompany(file: any) {
	const formData = new FormData();
	formData.append('file', file);
	return request({
		url: '/api/v1/company/_import',
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data'
		}
	});
}
